1886B - Fear of the Dark - CodeForces Solution


geometry

Please click on ads to support us..

C++ Code:

#include <iomanip>
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <algorithm>
using namespace std;
#define IOS  ios::sync_with_stdio(false);
#define CIT  cin.tie(0);
#define COT  cout.tie(0);
 #define int long long
#define ll long long
#define x first
#define y second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),x.end()
#define Fup(i,a,b) for(int i=a;i<=b;i++)
#define Fde(i,a,b) for(int i=a;i>=b;i--)
#define NO cout<<"NO"<<endl;
#define YES cout<<"YES"<<endl;
#define cer(a) cerr<<#a<<'='<<(a)<<" @ line "<<__LINE__<<" "<<endl
typedef priority_queue<int,vector<int>,greater<int> >  Pri_m;
typedef pair<int,int> pii;
typedef vector<int> VI;
map<int,int> mp;
const int N = 2e5+10,INF = 0x3f3f3f3f;
const double eps = 1e-5;
double dis(double a,double b,double c,double d)
{
	double t = sqrt((a-c)*(a-c)+(b-d)*(b-d));
	return t;
}
void solve()
{
	double x1,y1,x2,y2,x3,y3;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	double d1 = dis(0,0,x2,y2);
	double d2 = dis(0,0,x3,y3);
	double d3 = dis(x1,y1,x2,y2);
	double d4 = dis(x1,y1,x3,y3);
	double d5 = min(max(d1,d3),max(d2,d4));
	double d7 = dis(x2,y2,x3,y3)/2.0;
	double ans = min(d5,max(max(d1,d4),d7));
	ans = min(ans,max(max(d2,d3),d7));
	cout << ans << endl;
	
	
 	
} 
signed main()
{
	IOS
	CIT
	COT
	cout << fixed << setprecision(10);
	int tt;
	cin>>tt;
	while(tt--)
		solve(); 
	return 0;
}









Comments

Submit
0 Comments
More Questions

Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix